import request from "@/utils/request";
import { GetAttrListApiParams, AttrList, AttrsItem } from "./model/attrModel";

const enum Api {
  attrList = "/admin/product/attrInfoList",
  addOrUpdateAttr = "/admin/product/saveAttrInfo",
  delAttr = "/admin/product/deleteAttr",
}

export const getAttrListApi = ({
  category1Id,
  category2Id,
  category3Id,
}: GetAttrListApiParams) => {
  return request.get<any, AttrList>(
    Api.attrList + `/${category1Id}/${category2Id}/${category3Id}`
  );
};

export const addAttrListApi = (data: AttrsItem) => {
  return request.post<any, null>(Api.addOrUpdateAttr, data);
};

export const delAttrApi = (id: number) => {
  return request.delete<any, null>(Api.delAttr + `/${id}`);
};
